<html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <form id="app">
        <div>
            <label>书名：</label>
            <input type="text" v-model="name">
        </div>
       <div>
           <label>作者：</label>
           <input type="text" v-model="author">
       </div>
       <div>
           <label>出版日期：</label>
           <input type="date" v-model="date">
       </div>
       <div>
           <label>出版社：</label>
           <input type="text" v-model="press">
       </div>
        <div>
            <label>价格：</label>
            <input type="number" v-model="price">
        </div>
        <div>
            <input type="button" value="保存" id="saveBtn" @click="doSave()">
            <input type="reset" value="重置">
        </div>
    </form>
</body>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script>
    Vue.createApp({
        data(){
            return{
                name:"",
                author:"",
                date:"",
                press:"",
                price:0
            }
        },
        methods:{
            async doSave(){
                const {data} = await axios.post('/bms/book',
                    {
                        id: this.id,
                        name: this.name,
                        author: this.author,
                        date: this.date,
                        press: this.press,
                    }
                );
                if (data > 0) {
                    location = "/bms/page_book/bookIndex.html";
                }else{
                    alert("保存失败");
                }
            }
        }
    }).mount('#app');
</script>
</html>
